package com.tudouji.project.harvest.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.harvest.domain.DpriceApply;
import com.tudouji.project.harvest.service.IDpriceApplyService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 淀粉薯定价Controller
 * 
 * @author tudouji
 * @date 2022-10-27
 */
@RestController
@RequestMapping("/harvest/dpriceApply")
public class DpriceApplyController extends BaseController
{
    @Autowired
    private IDpriceApplyService dpriceApplyService;

    /**
     * 查询淀粉薯定价列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(DpriceApply dpriceApply)
    {
        startPage();
        List<DpriceApply> list = dpriceApplyService.selectDpriceApplyList(dpriceApply);
        return getDataTable(list);
    }

    /**
     * 导出淀粉薯定价列表
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:export')")
    @Log(title = "淀粉薯定价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DpriceApply dpriceApply)
    {
        List<DpriceApply> list = dpriceApplyService.selectDpriceApplyList(dpriceApply);
        ExcelUtil<DpriceApply> util = new ExcelUtil<DpriceApply>(DpriceApply.class);
        return util.exportExcel(list, "dpriceApply");
    }

    /**
     * 获取淀粉薯定价详细信息
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(dpriceApplyService.selectDpriceApplyById(guid));
    }

    /**
     * 新增淀粉薯定价
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:add')")
    @Log(title = "淀粉薯定价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DpriceApply dpriceApply)
    {
        return toAjax(dpriceApplyService.insertDpriceApply(dpriceApply));
    }

    /**
     * 修改淀粉薯定价
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:edit')")
    @Log(title = "淀粉薯定价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DpriceApply dpriceApply)
    {
        return toAjax(dpriceApplyService.updateDpriceApply(dpriceApply));
    }

    /**
     * 删除淀粉薯定价
     */
    @PreAuthorize("@ss.hasPermi('harvest:dpriceApply:remove')")
    @Log(title = "淀粉薯定价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(dpriceApplyService.deleteDpriceApplyByIds(guids));
    }
}
